package my.system.ip6;

import java.net.InetAddress;

/**
 * @blog http://www.micmiu.com
 * @author Michael
 */
public class TestInetAddress {

    /**
     * @param args
     */
    public static void main(String[] args) throws Exception {
        // 注释指定系统属性值
//         System.setProperty("java.net.preferIPv4Stack", "true");
         System.setProperty("java.net.preferIPv6Addresses", "true");
        System.out.println("-------InetAddress.getLocalHost()");
        InetAddress addr = InetAddress.getLocalHost();
        System.out.println("HostName := " + addr.getHostName());
        System.out.println("HostAddress := " + addr.getHostAddress());

        System.out.println("-------InetAddress.getByName(\"restapi.amap.com\")");
        InetAddress addr2 = InetAddress.getByName("restapi.amap.com");
        System.out.println("HostName := " + addr2.getHostName());
        System.out.println("HostAddress := " + addr2.getHostAddress());

    }
}
